package com.example.tys.baseapplication.View;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.FrameLayout;

/**
 * Created by tys on 2019/4/14.
 */

public class MyFrameLayout extends FrameLayout{
    private static final String TAG = "MyFrameLayout";
    public MyFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }


    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        String act = "";
        final int action = ev.getAction();
        switch (action) {
            case MotionEvent.ACTION_DOWN:
                act = "down";
                break;
            case MotionEvent.ACTION_MOVE:
                act = "move";
                return true;
//                break;
            case MotionEvent.ACTION_UP:
                act = "up";
                break;
            case MotionEvent.ACTION_CANCEL:
                act = "cancel";
                break;
            default:
        }
        Log.e(TAG, "onInterceptTouchEvent "+ act);
        return false;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        String act = "";
        final int action = event.getAction();
        switch (action) {
            case MotionEvent.ACTION_DOWN:
                act = "down";
                break;
            case MotionEvent.ACTION_MOVE:
                act = "move";
                break;
            case MotionEvent.ACTION_UP:
                act = "up";
                break;
            case MotionEvent.ACTION_CANCEL:
                act = "cancel";
                break;
            default:
        }
        Log.e(TAG, "onTouchEvent " + act);
        return false;
    }
}
